(function() {

    "use strict";

    describe("Module2TestCase", function() {

        beforeEach(function() {
			var core = new nw.Core();

			this.sandbox = new nw.Sandbox(core);
			this.sandbox.render = window.stubFn();
            this.sandbox.goView = window.stubFn();
            this.sandbox.show = window.stubFn();
            this.sandbox.hide = window.stubFn();

			this.module = new nw.module.M2(this.sandbox);
        });

		it("should not call render if currentViewName doesn't equals v2", function() {
			var currentViewName = this.sandbox.views().v3;
			this.sandbox.getCurrentViewName = function() {
				return currentViewName;
			};
			this.module.render();
			expect(!this.sandbox.render.called).to.be.ok();
		});

		it("should call render if currentViewName equals v2", function() {
			var currentViewName = this.sandbox.views().v2;
			this.sandbox.getCurrentViewName = function() {
				return currentViewName;
			};
            this.sandbox.onClick = window.stubFn();
			this.module.render();
			expect(this.sandbox.render.called).to.be.ok();
		});

        it("should bind goView1 action", function() {
            this.sandbox.onClick = window.stubFn2();
            var currentViewName = this.sandbox.views().v2;
            this.sandbox.getCurrentViewName = function() {
                return currentViewName;
            };
            this.module.render();
            expect(this.sandbox.onClick.calls[0].called).to.be.ok();
            expect(this.sandbox.onClick.calls[0].args[0]).to.eql(this.module._mapping.goView1);
        });

        it("should bind goView3 action", function() {
            this.sandbox.onClick = window.stubFn2();
            var currentViewName = this.sandbox.views().v2;
            this.sandbox.getCurrentViewName = function() {
                return currentViewName;
            };
            this.module.render();
            expect(this.sandbox.onClick.calls[1].called).to.be.ok();
            expect(this.sandbox.onClick.calls[1].args[0]).to.eql(this.module._mapping.goView3);
        });

        it("should go to the View2", function() {
            this.module._goView1();
            expect(this.sandbox.goView.called).to.be.ok();
            expect(this.sandbox.goView.args[0]).to.eql(nw.enums.views.v1);
        });

        it("should go to the View3", function() {
            this.module._goView3();
            expect(this.sandbox.goView.called).to.be.ok();
            expect(this.sandbox.goView.args[0]).to.eql(nw.enums.views.v3);
        });

        it("should call show through sandbox", function() {
            this.module.show();
            expect(this.sandbox.show.called).to.be.ok();
            expect(this.sandbox.show.args[0]).to.eql(this.module._mapping.container);
        });

        it("should call hide through sandbox", function() {
            this.module.hide();
            expect(this.sandbox.hide.called).to.be.ok();
            expect(this.sandbox.hide.args[0]).to.eql(this.module._mapping.container);
        });
    });

}());